<!DOCTYPE html>
<html ng-app="app" ng-controller="indexCtrl">

	<head lang="en">
		<meta charset="UTF-8">
		<meta http-equiv="Expires" content="0">
		<meta http-equiv="Pragma" content="no-cache">
		<meta http-equiv="Cache-control" content="no-cache">
		<meta http-equiv="Cache" content="no-cache">
		<title>广告投放-广告主</title>
		<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" id="favicon">
		<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css" />
		<link rel="stylesheet" href="css/base.css" />
		<link rel="stylesheet" href="modules/agent/agNewActive/agNewActive.css" />
		<link rel="stylesheet" href="../../oem/css/common.css" />

		<style>

		</style>
	</head>

	<body>
		<div class="nav_top">
			<div class="logo fl" id="logo">
			</div>
			<ul class="nav_list fl">
			
				<li>
					<a href="agentIndex.html" >首页</a>
				</li>
	
				<li>
					
					<a href="active.html" class="toFirstSub active">投放管理</a>
					<ul class="nav_dropdown" style="width: 1903px;">
						
						<li>
							<a href="active.html" >活动管理</a>
						</li>
						
						<li>
							<a href="order.html">订单管理</a>
						</li>
						
						<li>
							<a href="creative.html">素材信息</a>
						</li>
						
						<li>
							<a href="audiences.html">监测管理</a>
						</li>
						
					</ul>
				</li>
				<li>

					<a href="baoBiao.html" class="toFirstSub">报表中心</a>
					<ul class="nav_dropdown" style="width: 1903px;">

						<li>
							<a href="baoBiao.html">效果报表</a>
						</li>
						<li ng-if="permission.view['合约报表'].sub['效果报表']" class="ng-scope">
							<a href="./heyuebaobiao.html" ui-sref-active="active" ui-sref="agent.report.effect({'activeID':'0','activeName':'0','orderID':'0','orderName':'0'})" class="">合约报表</a>
						</li>
					</ul>
				</li>
				<li>
					<a href="baseInfo.html" class="toFirstSub">系统管理</a>
					<ul class="nav_dropdown" style="width: 1903px;">

						<li>
							<a href="baseInfo.html">基本信息</a>
						</li>

						<li>
							<a href="qualifications.html">资质管理</a>
						</li>

					</ul>
				</li>
				<li>

					<a href="caiwu.html" class="toFirstSub">财务管理</a>
					<ul class="nav_dropdown" style="width: 1903px;">

						<li>
							<a href="caiwu.html">财务信息</a>
						</li>

					</ul>
				</li>
			</ul>
			<div class="user">
				<div class="user-avatar"></div>
				<div class="user-info">
					<p></p>
					<p></p>
				</div>
				<ul class="user-list">
					<li>余额：</li>
					<li>退出登录</li>
				</ul>
			</div>
		</div>
		<ui-view class="ng-scope">
			<!-- uiView:  -->
			<ui-view class="ng-scope">
				<div class="newActive-page page ng-scope">
					<!--页面标题-->
					<h3 class="page-title ng-binding">新建活动</h3>

					<!--form表单-->
					<div class="form cl">
						<div class="form-group">
							<label><span class="star">*</span>活动名称：</label>
							<input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-empty" placeholder="请输入活动名称" ng-model="obj.dataObj.name" id="huoDong">
						</div>
						<div class="form-group">
							<label><span class="star">*</span>活动时间：</label>
							<div class="flatform cl">
								<div class="fl">
									<div class="dropdown data_show fl" style="margin-left: 0px;">
										<input type="text" id="test1" class="btn btn-default dropdown-toggle ng-binding">
										<span class="caret"></span>
									</div>
									&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;&nbsp;
									<span class="fr"> 长期投放 ( 仅设置开始时间 )</span>
									<!-- <div class="check ng-isolate-scope" ng-class="{disabled:disabled,checked:value === undefined?module:module.indexOf(value) !== -1}" ng-click="clickFunc()" value="value" module="module" callback="checkTimeback"><b></b><span ng-transclude=""></span></div> -->
									<div class="check ng-isolate-scope checked" id="duoXuan1"><b></b><span ng-transclude=""></span></div>
									<div class="dropdown data_show fr" style="margin-right: 0px;">
										<button style="border:0;background-color: rgba(255, 255, 255, 1);">
                                        <input type="text" id="test2" class="btn btn-default dropdown-toggle ng-binding"
                                            disabled="disabled">
                                    </button>
										<!-- <button class="btn btn-default dropdown-toggle ng-binding" type="button" id="dpd2" data-toggle="dropdown" ng-disabled="timeLimit" style="width: 197px;height: 30px;" ng-bind="timeLimit? '' : obj.end"></button> -->

										<span class="caret"></span>
									</div>

								</div>
							</div>
						</div>
						<div class="form-group cl">
							<label><span class="star">*</span>总预算：</label>
							<div class="checkInput ng-isolate-scope" module="checkAll" value="1" module-input="obj.dataObj.totalBudget" callback="allCall"> <input type="text" class="form-check-input ng-pristine ng-untouched ng-valid ng-not-empty" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" disabled="disabled" id="allBudget">
								<div class="check ng-isolate-scope checked wuYuSuan" ng-class="{disabled:disabled,checked:value === undefined?module:module.indexOf(value) !== -1}" ng-click="clickFunc()" value="1" module="module" callback="checkCallback"><b></b><span ng-transclude=""></span></div>
							</div><span class="fl">无预算限制</span>
						</div>

						<div class="form-group cl">
							<label>每日预算：</label>
							<div>
								<div class="checkInput ng-isolate-scope" module="checkDay" value="2" module-input="obj.dataObj.dayBudget" callback="dayCall"> <input type="text" class="form-check-input ng-pristine ng-untouched ng-valid ng-not-empty" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" disabled="disabled" id="dayBudget">
									<div class="check ng-isolate-scope checked wuYuSuan" ng-class="{disabled:disabled,checked:value === undefined?module:module.indexOf(value) !== -1}" ng-click="clickFunc()" value="2" module="module" callback="checkCallback">
										<b></b><span ng-transclude=""></span></div>
								</div><span class="fl">无预算限制</span>
							</div><br>
							<!--<span class="yusuan">-->
							<!--当展示量达到-->
							<!--<input type="text" class="form-control" />-->
							<!--千次 时，活动下的广告单元停止投放。-->
							<!--</span>-->
						</div>
						<div class="form-group frequency">
							<label>频次控制：</label>
							<!--<radio module='radios' value="1">radio1</radio>-->
							<!--<radio module='radios' value="2">radio2</radio>-->
							<input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-empty" ng-model="obj.dataObj.frequency" id="times">次/&nbsp;&nbsp;&nbsp;&nbsp;
							<div class="dropdown dropdown-filter ng-isolate-scope" ng-class="{disabled:disabled}" list="select" callback="daySelect"> <button class="btn btn-default dropdown-toggle cl" data-toggle="dropdown"> <span style="width: 55%; display: inline-block;"
                                    class="ng-binding" id="tian">天</span> 
                              
                            </button> <span class="caret"></span>
								<ul class="dropdown-menu">
									<li class="cl ng-scope" onclick="selectTianShi(this)">
										<a title="天" href="javascript:;" class="ng-binding">天</a>
									</li>
									<!--<li class="cl ng-scope" onclick="selectTianShi(this)">
										<a title="小时" href="javascript:;" class="ng-binding">小时</a>
									</li>-->
								</ul>
							</div>
						</div>
						<div class="form-group chooseType">
							<label><span class="star">*</span>行业分类：</label>
							<div class="dropdown dropdown-filter ng-isolate-scope" ng-class="{disabled:disabled}" list="firstList" callback="firstCall"> <button class="btn btn-default dropdown-toggle cl" data-toggle="dropdown"> <span style="width: 55%; display: inline-block;"
                                    class="ng-binding" id="changeText1">请选择</span> 
                              
                            </button> <span class="caret"></span>
								<ul class="dropdown-menu" id="hangye">
									<!-- <li class="cl ng-scope"> 
                                    <a title="技术与计算" href="javascript:;" class="ng-binding">技术与计算</a> 
                                </li> -->

								</ul>
							</div>
							<div class="dropdown dropdown-filter ng-isolate-scope" ng-class="{disabled:disabled}" list="secondList" callback="secondCall"> <button class="btn btn-default dropdown-toggle cl" data-toggle="dropdown"> <span style="width: 55%; display: inline-block;"
                                    class="ng-binding" id="changeText2">请选择</span> 
                                  
                            </button> <span class="caret"></span>
								<ul class="dropdown-menu" id="xiaoFenLei">

								</ul>
							</div>
						</div>
					</div>
					<div class="btns">
						<button type="button" class="btn btn-info" id="save">保存</button>
						<!-- ngIf: permission.act["订单"].sub["新建"] -->
						<button type="button" class="btn fr btn-info cancel" ui-sref="agent.delivery.active" href="#/agent/1/13197/delivery/active">取消</button>
					</div>

					<div class="orderType">
						<a ng-click="addOrder('1')">
							<div>
								<img src="./images/pic-contract.png" alt="">
							</div>
							<p>竞价交易</p>
						</a>
						<a ng-click="addOrder('2')">
							<div>
								<img src="./images/pic-bid.png" alt="">
							</div>
							<p>合约交易</p>
						</a>
					</div>
				</div>
			</ui-view>
		</ui-view>

	</body>

</html>
<script src="../res1.hubcloud.com.cn/lib/jquery/jquery.min.js"></script>

<script src="../res1.hubcloud.com.cn/lib/layer/layer.js"></script>
<script src="../res1.hubcloud.com.cn/lib/bootstrap/js/bootstrap.min.js"></script>
<script src="../res1.hubcloud.com.cn/lib/calendar/calendar.js"></script>

<script src="../res1.hubcloud.com.cn/lib/qiniu/plupload/moxie.js"></script>
<script src="../res1.hubcloud.com.cn/lib/query.js"></script>
<script src="../res1.hubcloud.com.cn/lib/paging.js"></script>
<script src="js/commen.js?rand=v1.0.54"></script>
<script src="./layui/laydate/laydate.js"></script>
<script src="js/js_1.js"></script>
<script>
	$(function() {

		$('.user').on('click', function() {
			$(this).toggleClass('hover');
		})

		$('.user').mouseleave(function() {
			$(this).removeClass('hover');
		});

		//执行一个laydate实例
		laydate.render({
			elem: '#test1' //指定元素
		});

		laydate.render({
			elem: '#test2'
		});

		$("#duoXuan1").on('click', function() {
			if($(this).hasClass("checked")) {
				$(this).removeClass('checked');
				$('#test2').removeAttr('disabled');

			} else {
				$('#test2').val('');
				$('#test2').attr('disabled', 'disabled');
				$(this).addClass('checked');
			}
		})

		$('.wuYuSuan').on('click', function() {
			if($(this).hasClass("checked")) {
				$(this).removeClass('checked');
				$(this).prev().removeAttr('disabled');
			} else {

				$(this).addClass('checked');
				$(this).prev().attr('disabled', 'disabled');
			}
		})

		$('.cancel').on('click', function() {
			location.href = './active.html';
		})

		$('#save').on('click', function() {
			addAdActivity();
		})

		let time1 = CurentTime();
		$('#test1').val(time1);

		getLoadData();

	})

	//新建活动
	function addAdActivity() {

		let huoDong = $('#huoDong').val();
		let acTimeStart = $('#test1').val();
		let acTimeEnd = $('#test2').val();
		let allBudget = $('#allBudget').val();
		let dayBudget = $('#dayBudget').val();
		let times = $('#times').val();
		let unit = $('#tian').text();

		let profession = $('#changeText1').text();

		let vocation = $('#changeText2').text();


		if(!huoDong) {
			layer.msg("请输入活动名称");
			return false;
		}
		if(!acTimeStart) {
			layer.msg("请选择活动开始时间");
			return false;
		}
		if(vocation == "请选择") {
			layer.msg("请选择行业分类");
			return false;
		}

		var d = {};
		d.acTimeEnd = acTimeEnd;
		d.acTimeStart = acTimeStart;
		d.allBudget = allBudget;
		d.dayBudget = dayBudget;
		d.name = huoDong;
		d.times = times;
		d.unit = unit;
		d.profession = profession;
		d.vocation = vocation;
		let token = sessionStorage.getItem("token");
		$.ajax({
			url: url + "/advertiser/adActivity/addAdActivity",
			type: 'POST',
			//		参数需转为字符串
			data: JSON.stringify(d),
			//		json跨域
			dataType: 'json',
			//		contentType类型为json
			contentType: "application/json",

			//		请求头加上X-Token 
			 beforeSend: function(XMLHttpRequest) {
				//		token 为页面所获取
				   
				XMLHttpRequest.setRequestHeader("X-Token", token); 
			},
			useDefaultXhrHeader: false,
			success: function(result) {
		
				if(result.code == '0') {
					layer.open({
						title: '提示',
						icon: '1',
						content: result.msg,
						time: 1500,
						end: function() { 
							location.href = 'active.html'        
						}
					});
				} else {
					layer.msg(result.msg);
				}
			},
			err: function(err) {
				layer.msg(result.msg);
			},
			complete: function() {

			}
		});
	}

	//获取行业大类列表
	function getLoadData() {
		$.ajax({
			url: url + "/common/industryBig",
			type: 'POST',
			//		参数需转为字符串
			data: {},
			//		json跨域
			dataType: 'json',
			//		contentType类型为json
			contentType: "application/json",

			//		请求头加上X-Token 
			beforeSend: function(XMLHttpRequest) {
				//		token 为页面所获取

				//			XMLHttpRequest.setRequestHeader("X-Token", token); 
			},
			useDefaultXhrHeader: false,
			success: function(result) {
				let html = '';
				result.data.forEach(item => {
					html += `<li class="cl ng-scope" dataId="${item.id}" onclick='select1(this)'> 
                                <a title="${item.industryImages}" href="javascript:;" class="ng-binding">${item.industryImages}</a> 
                            </li>`;

				})
				$('#hangye').append(html);

				// if(result.code == '0') {
				//     layer.msg("登录成功");
				//     var data=result.data;
				//     localStorage.setItem("token",data.token);

				//     // id:6
				//     // token:"61709a79-0317-4755-9282-a1fcde3a9a05"
				//     // userType:2
				//     // username:"ggz"

				//     location.href="agentIndex.html?token="+data.token+"&id="+data.id;
				// } else {
				//     isErr(result);
				// }
			},
			err: function(err) {
				layer.msg("请求失败");
			},
			complete: function() {

			}
		});
	}

	//当前日期加时间(如:2009-06-12 12:00)
	function CurentTime() {
		var now = new Date();

		var year = now.getFullYear(); //年
		var month = now.getMonth() + 1; //月
		var day = now.getDate(); //日

		// var hh = now.getHours();            //时
		// var mm = now.getMinutes();          //分

		var clock = year + "-";

		if(month < 10)
			clock += "0";

		clock += month + "-";

		if(day < 10)
			clock += "0";

		clock += day + " ";

		// if(hh < 10)
		//     clock += "0";

		// clock += hh + ":";
		// if (mm < 10) clock += '0'; 
		// clock += mm; 
		return clock;
	}

	//根据行业大类ID获取 行业小类列表
	function getIndustrySmallData(id) {
	
		$.ajax({
			url: url + "/common/industrySmall/" + id,
			type: 'POST',
			//		参数需转为字符串
			data: {},
			//		json跨域
			dataType: 'json',
			//		contentType类型为json
			contentType: "application/json",

			//		请求头加上X-Token 
			beforeSend: function(XMLHttpRequest) {
				//		token 为页面所获取

				//			XMLHttpRequest.setRequestHeader("X-Token", token); 
			},
			useDefaultXhrHeader: false,
			success: function(result) {
		
				let html = '';
				result.data.forEach(item => {
				
					html += `<li class="cl ng-scope" dataId="${item.id}" onclick='select2(this)'> 
                                <a title="${item.industryImages}" href="javascript:;" class="ng-binding">${item.industryImages}</a> 
                            </li>`;

				})
				$('#xiaoFenLei').append(html);

				// if(result.code == '0') {
				//     layer.msg("登录成功");
				//     var data=result.data;
				//     localStorage.setItem("token",data.token);

				//     // id:6
				//     // token:"61709a79-0317-4755-9282-a1fcde3a9a05"
				//     // userType:2
				//     // username:"ggz"

				//     location.href="agentIndex.html?token="+data.token+"&id="+data.id;
				// } else {
				//     isErr(result);
				// }
			},
			err: function(err) {
				layer.msg("请求失败");
			},
			complete: function() {

			}
		});
	}

	function select1(e) {
		$('#changeText1').text($(e).children('a').text());
		let id = $(e).attr("dataid");
		getIndustrySmallData(id);

	}

	function select2(e) {
		$('#changeText2').text($(e).children('a').text());
	}

	function selectTianShi(e) {
		$('#tian').text($(e).children('a').text());
	}
</script>
<script src="../../oem/js/oem.js"></script>